package com.mk.base.model.response;

import java.io.Serializable;

/**
 * Created by yanzhiping on 2017/9/5.
 */
public class RspPage<T> implements Serializable {

    private int current;//当前第几页
    private int pages;//总共页数
    private int size;//每页几条数据
    private int total;//总共记录条数
    private boolean success;
    private T data;
    private String error;

    public static <T> RspPage<T> SUCCESS(int current, int pages, int size, int total, T data){
        return new RspPage<T>(current,pages,size,total,true,data);
    }

    public static RspPage ERROR(String error){
        return new RspPage(false,error);
    }

    public RspPage(int current, int pages, int size, int total, boolean success, T data) {
        this.current = current;
        this.pages = pages;
        this.size = size;
        this.total = total;
        this.success = success;
        this.data = data;
    }

    public RspPage(boolean success, String error) {
        this.success = success;
        this.error = error;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    @Override
    public String toString() {
        return "RspPage{" +
                "current=" + current +
                ", pages=" + pages +
                ", size=" + size +
                ", total=" + total +
                ", success=" + success +
                ", data=" + data +
                ", error='" + error + '\'' +
                '}';
    }
}
